#!/bin/bash

if [ "$#" -eq 0 ]; then
 if [ -L /etc/resolv.conf ]; then
   x=`file /etc/resolv.conf | awk '{print $5}'`
   status=`echo ${x%?} | cut -c 2-`
   if [ $status = "/etc/resolv.conf.network" ]; then
    echo "net" 
   elif [ $status = "/etc/resolv.conf.internet" ]; then
    echo "int" 
   else
    echo "none" 
   fi
 else
   echo "file"
 fi
 exit 0;
fi

# if arg0 is "net" then
if [ "$1" = "net" ]; then
 if [ -f /etc/resolv.conf.network ]; then
   if [ -f /etc/resolv.conf ]; then
    sudo rm /etc/resolv.conf
   fi
   sudo ln -s /etc/resolv.conf.network /etc/resolv.conf
 else
  echo "/etc/resolv.conf.network not exists!"
 fi
fi

# if arg0 is "int" then
if [ "$1" = "int" ]; then
 if [ -f /etc/resolv.conf.internet ]; then
   if [ -f /etc/resolv.conf ]; then
    sudo rm /etc/resolv.conf
   fi
   sudo ln -s /etc/resolv.conf.internet /etc/resolv.conf
 else
  echo "/etc/resolv.conf.internet not exists!"
 fi
fi
